package com.framework.controller.yhbcontroller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.*;
import com.framework.yhbEntity.Index.YhbIndex;
import com.framework.yhbEntity.notice.YhbNotice;
import com.framework.yhbEntity.user.YhbUserOrder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 功能描述:h5统一接口 不需要参数加密校验和token
 *
 * @author ck
 * @date 2018/11/16 14:01
 */
@RestController
@Api(value = "h5统一接口", tags = {"h5统一接口"})
@RequestMapping(value = "yhbh5")
public class YhbApiController {


    @Autowired
    private YhbNoticeService yhbNoticeService;
    @Autowired
    private YhbIndexService yhbIndexService;
    @Autowired
    private YhbCurrentCountService yhbCurrentCountService;

    @Autowired
    private YhbTerminalService yhbTerminalService;

    @Autowired
    private YhbUserOrderService yhbUserOrderService;



    /**
     * H5上注册
     * @param phone
     * @param password
     * @param confPassword
     * @param smsCode
     * @param pid
     * @param name
     * @return
     @PostMapping("notValidate/register")
     @ApiOperation("H5上注册")
     @ApiImplicitParams({
     @ApiImplicitParam(name="phone",value="手机号码",dataType="string", paramType = "query" ,required = true),
     @ApiImplicitParam(name="password",value="密码",dataType="string", paramType = "query",required = true),
     @ApiImplicitParam(name="confPassword",value="确认密码",dataType="string", paramType = "query",required = true),
     @ApiImplicitParam(name="smsCode",value="验证码",dataType="string", paramType = "query",required = true),
     @ApiImplicitParam(name="pid",value="推荐码",dataType="Long", paramType = "query",required = true),
     @ApiImplicitParam(name="name",value="真实姓名",dataType="string", paramType = "query",required = true),
     @ApiImplicitParam(name="deptId",value="渠道id",dataType="Long", paramType = "query",required = true)})
     public RespResult register(String phone, String password, String confPassword, String smsCode, Long pid, String name,Long deptId) {
     agentService.register(phone,password,confPassword,smsCode,pid,name, deptId);
     return RespResult.ok();
     }*/

    /**
     * 系统通知详情
     *
     * @param noticeNo
     * @return
     */
    @GetMapping("notValidate/querySysNoticeInfo")
    @ApiOperation("系统通知详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noticeNo", value = "唯一id", dataType = "string", paramType = "query", required = true)
    })
    public RespResult querySysNoticeInfo(String token, String noticeNo) {
        YhbNotice info = yhbNoticeService.queryNoticeByNo(token, noticeNo);
        return RespResult.ok().put("info", info);
    }

    /**
     * Banner图详情
     *
     * @param id
     * @return
     */
    @GetMapping("notValidate/geHomeBanner")
    @ApiOperation("首页轮播图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "所属Banner图Id", dataType = "long", paramType = "query", required = true)
    })
    public RespResult getHomeBanner(Long id) {
        YhbIndex info = yhbIndexService.queryBannerInfoById(id);
        return RespResult.ok().put("info", info);
    }

    /**
     * 账单详情
     *
     * @param token
     * @return
     */
    @PostMapping("notValidate/getCurrentCountInfoList")
    @ApiOperation("获取账单详情")
    @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "String", paramType = "query", required = true)
    public RespResult getCurrentCountInfoList(String token, Integer pageNo) {
        List<Map<String, Object>> list = yhbCurrentCountService.getCurrentCountInfoList(token, pageNo);
        return RespResult.ok().put("list", list);
    }


    /**
     * 冻结详情
     *
     * @param token
     * @return
     */
    @PostMapping("notValidate/queryFreezenFlow")
    @ApiOperation("冻结详情")
    @ApiImplicitParam(name = "token", value = "登录产生的token", dataType = "String", paramType = "query", required = true)
    public RespResult queryFreezenFlow(String token, Integer pageNo) {
        List<Map<String, Object>> list = yhbCurrentCountService.queryFreezenFlow(token, pageNo);
        return RespResult.ok().put("list", list);
    }

    /**
     * 获取用户活动类型机器
     * @return
     */
    @GetMapping("notValidate/getActivityTerminal")
    @ApiOperation("获取用户活动类型机器")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "terminalType", value = "机具类型", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query", required = true)
    })
    public RespResult getActivityTerminal(String userId,String terminalType){
        List<String> list=yhbTerminalService.getActivityTerminal(userId,terminalType);
        return RespResult.ok().put("list",list);

    }
    /**
     * 添加订单
     * @return
     */
    @PostMapping("notValidate/addOrder")
    @ApiOperation("添加订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sn", value = "机具类型", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "activityId", value = "活动id", dataType = "integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "orderNo", value = "订单号", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "payAmount", value = "支付金额", dataType = "double", paramType = "query", required = true)
    })
    public RespResult addOrder(String userId, String sn, Integer activityId,String orderNo,BigDecimal payAmount){
        yhbUserOrderService.addOrder(userId, sn, activityId,orderNo,payAmount);
        return RespResult.ok();
    }
}
